<?php

namespace Tasker\Models;

class DepartmentModel extends BaseModel
{

	public function getDepartments(array $where=array())
	{
		return $this->connection->department();
	}

	public function getDepartment(array $where)
	{
		return $this->connection->department[$where];
	}

	public function getSkills(array $where=array())
	{
		return $this->connection->skill()->where($where);
	}

	public function getSkill(array $where)
	{
		return $this->connection->skill[$where];
	}

	public function addDepartment($values)
	{
		$n_values = array(
			'name' => $values['name'],
			);
		return $this->connection->department()->insert($n_values);
	}

	public function editDepartment($values)
	{
		$id = $values['id'];
		unset($values['id']);
		return $this->connection->department[$id]->update((array)$values);
	}

	public function deleteDepartment($id)
	{
		return $this->connection->department[$id]->delete();
	}

	public function addSkill($name, $department)
	{
		$values = array(
			'name' => $name,
			'department_id' => $department
		);
		return $this->connection->skill()->insert($values);
	}

	public function editSkill($values)
	{
		$id = $values['id'];
		unset($values['id']);
		return $this->connection->skill[$id]->update((array)$values);
	}

	public function deleteSkill($id)
	{
		return $this->connection->skill[$id]->delete();
	}

}
